import java.util.Scanner;

public class Test {
    public static void fnid_val(int [][]arr,int row,int col,int num) {
        if(arr[0][0] > num) {
            System.out.println("数组中不存在该数字");
            return;
        }
        int tmprow = 0,tmpcol = col;
        //每次从最右上角来比较大小，每次比较可以消除一行或者一列
        while(tmprow <= row && tmpcol >= 0) {
             if(num > arr[tmprow][tmpcol]) {
                tmprow++;
            } else if(num < arr[tmprow][tmpcol]){
                tmpcol--;
            } else {
                System.out.println("在row=" + tmprow + ",col=" + tmpcol + "处找到了该数字");
                return;
            }
        }
    }
    public static void main(String[] args) {
        int [][]array = {
                {1,2,8,9},
                {2,4,9,12},
                {4,7,10,13},
                {6,8,11,15}
        };
        fnid_val(array,3,3,10);

    }
}
